//
//  PayMoneyControl.m
//  FreeTime
//
//  Created by  on 16/8/25.
//  Copyright © 2016年 SRDZ.com. All rights reserved.
//

#import "PayMoneyControl.h"
#import "Header.h"

@interface PayMoneyControl (){
    NSMutableArray * chooseArray;
}

@end

@implementation PayMoneyControl

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    [self setupNav];
    
}
#pragma mark -- selfStyle --

- (void)setupUI{
    chooseArray = [NSMutableArray array];
    self.navigationItem.title = @"提交支付";
    UIView * bgView = [[UIView alloc] init];
    UIImageView * iconImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(10, 15, 72, 72) imageName:@"123" isCorner:YES];
    [bgView addSubview:iconImg];
    
    UIImageView * sexImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(CGRectGetMaxX(iconImg.frame)+10, 26, 10, 10) imageName:@"nvsheng" isCorner:NO];
    [bgView addSubview:sexImg];
    CGFloat w = [ToolUtil autoWidth:@"你猜我想静静不 31" width:0 height:10 num:12];
    UILabel * nameLbl = [ReduceCode creatLabelWithFrame:CGRectMake(CGRectGetMaxX(sexImg.frame)+5, sexImg.frame.origin.y, w, 10) title:@"你猜我想静静不 31" titleColor:[ImageUtil colorWithRgb:0x666666] font:12 textAlignment:0];
    [bgView addSubview:nameLbl];
    NSArray * contentArr = @[@"ID: 210303",@"时薪:200/小时"];
    NSArray * contentArr1 = @[@"服务时间: 2小时",@"活动内容:吃饭",@"支付总额:200.00元"];
    CGFloat y = 0;
    for (int i = 0; i<2; i++) {
        UILabel * lbl = [ReduceCode creatLabelWithFrame:CGRectMake(sexImg.frame.origin.x, CGRectGetMaxY(sexImg.frame)+5+15*i, 100, 10) title:contentArr[i] titleColor:[ImageUtil colorWithRgb:0xb3b3b3] font:10 textAlignment:0];
        [bgView addSubview:lbl];
    }
    for (int i = 0; i<3; i++) {
        UILabel * lbl1 = [ReduceCode creatLabelWithFrame:CGRectMake(10, CGRectGetMaxY(iconImg.frame)+10+45*i, WindowWidth-20, 45) title:contentArr1[i] titleColor:[ImageUtil colorWithRgb:0x666666] font:14 textAlignment:0];
        [bgView addSubview:lbl1];
        [ToolUtil createLine:44 superView:lbl1 lift:0 width:WindowWidth-20 hight:1 color:[ImageUtil colorWithRgb:0xe6e6e6]];
        y=CGRectGetMaxY(lbl1.frame);
    }
    
    UILabel * chooseLbl = [ReduceCode creatLabelWithFrame:CGRectMake(10, y+30, 70, 15) title:@"选择支付" titleColor:[ImageUtil colorWithRgb:0x4c4c4c] font:14 textAlignment:0];
    CGFloat y1 = [ToolUtil createLine:CGRectGetMaxY(chooseLbl.frame)+5 superView:bgView lift:10 width:60 hight:1 color:[ImageUtil colorWithRgb:0xb3b3b3]];
    [bgView addSubview:chooseLbl];
    
    NSArray * payImgArr = @[@"zhifubao",@"qianbao"];
    NSArray * payTitleArr = @[@"支付宝",@"钱包支付"];
    NSArray * chooseImgArr = @[@"meiqueding",@"queding"];
    CGFloat y2 = 0;
    for (int i = 0; i<2;i++ ) {
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(0, y1+10+i*65, WindowWidth, 65);
        [btn addTarget:self action:@selector(chooseBtn:) forControlEvents:UIControlEventTouchUpInside];
        btn.tag = 100+i;
        UIImageView * img1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 45, 45)];
        img1.image = [UIImage imageNamed:payImgArr[i]];
        [btn addSubview:img1];
        UILabel * chooseLbl = [ReduceCode creatLabelWithFrame:CGRectMake(CGRectGetMaxX(img1.frame)+15, 0, 70, 65) title:payTitleArr[i] titleColor:[ImageUtil colorWithRgb:0x4c4c4c] font:14 textAlignment:0];
        [btn addSubview:chooseLbl];
        UIImageView * img2 = [[UIImageView alloc] initWithFrame:CGRectMake(WindowWidth- 19, 55/2, 10, 10)];
        [chooseArray addObject:img2];
        if (i==0) {
            img2.image = [UIImage imageNamed:@"queding"];
        }else{
            img2.image = [UIImage imageNamed:@"meiqueding"];
        }
        [btn addSubview:img2];
        [bgView addSubview:btn];
        y2 = CGRectGetMaxY(btn.frame);
        if (i==0) {
            [ToolUtil createLine:64 superView:btn lift:10 width:WindowWidth-20 hight:1 color:[ImageUtil colorWithRgb:0xe6e6e6]];
        }

    }
    UIButton * payBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    payBtn.frame = CGRectMake(60, WindowHeight-67.5-44-30, WindowWidth-120, 44);
    [payBtn addTarget:self action:@selector(payBtn) forControlEvents:UIControlEventTouchUpInside];
//    payBtn.backgroundColor = HOME_COLOR;
    payBtn.layer.cornerRadius = 10;
    [payBtn setBackgroundImage:[UIImage imageNamed:@"querenbiao"] forState:UIControlStateNormal];
    UILabel * titleLbl = [ReduceCode creatLabelWithFrame:CGRectMake((WindowWidth-120-80)/2, 0, 80, 40) title:@"完成" titleColor:[UIColor whiteColor] font:14 textAlignment:1];
    [payBtn addSubview:titleLbl];
    [bgView addSubview:payBtn];
    
    
    bgView.frame = CGRectMake(0, 0, WindowWidth, WindowHeight);
    self.tableView.tableHeaderView = bgView;
    self.tableView.scrollEnabled = NO;
    self.tableView.tableFooterView = [UIView new];
    
}
#pragma mark -- button 响应事件 -- 
- (void)chooseBtn:(UIButton *)btn
{
    UIImageView *img1 = chooseArray[0];
    UIImageView *img2 = chooseArray[1];

    if (btn.tag == 100) {
        img1.image = [UIImage imageNamed:@"queding"];
        img2.image = [UIImage imageNamed:@"meiqueding"];
    }else{
        img2.image = [UIImage imageNamed:@"queding"];
        img1.image = [UIImage imageNamed:@"meiqueding"];
    }
}
- (void)payBtn{
    
}
@end
